<html lang="java">
<head>
    <title>123</title>
    <script type="text/javascript">
        window.onload = function () {
            //下拉框选中
            const mySelect = document.getElementById("mySelect");
            const opts = mySelect.options;
            for (let i = 0; i < opts.length; i++) {
                if (opts[i].value == ${dId!'0'}) {
                    opts[i].selected = true;
                }
            }

            //全选
            const alleIds = document.getElementById("alleIds");
            const eIds = document.getElementsByName("eIds");
            alleIds.onchange = function () {
                for (let i = 0; i < eIds.length; i++) {
                    eIds[i].checked = alleIds.checked;
                }
            }

        };

        //批量删除
        function todelete() {
            if (confirm("确定删除？")) {
                //设置隐藏域的值
                document.getElementById("method").value = "delete";
                //提交表单
                document.forms[1].submit();
            }
        }

        //导出
        function todaochu() {
            if (confirm("确定导出？")) {
                document.getElementById("method").value = "daochu";
                //提交表单
                document.forms[1].submit();
            }
        }
    </script>
    <style type="text/css">
        body {

            background-size: 100% 100%;
            height: 100%;
            width: 100%;
            text-align: center;
            margin-top: 50px;
            margin-left: auto;
        }

        table {
            text-align: center;
            margin: auto;
            text-decoration-color: #E3E6EB;
        }

        h1 {
            font-size: 35px;
            color: #5d5a8b;
        }
    </style>
</head>
<body style="background-image:url('/static/img/31.jpg');">
<h1>员工管理</h1>
<#--        超级管理员-->
<#if  currentUser.role.rLevel == 3>
    <form action="/record/selectemployee" method="post">
        <table cellpadding="8" cellspacing="1">
            <tr>
                <td>姓名：</td>
                <td><input type="text" value="${eName?if_exists}" name="eName"/></td>
                <td>所属部门：</td>
                <td>
                    <select name="dId" id="mySelect">
                        <option value="0">全部</option>
                        <#list  departments as department>
                            <option value="${department.dId?if_exists}">${department.dName?if_exists}</option>
                        </#list>
                    </select>
                </td>
                <td rowspan="2"><input type="submit" value="查询"></td>
            </tr>
        </table>
    </form>
    <div class="div_head" style="margin-left: 25% ; margin-top: auto">
            <span>
                    <span onclick="todaochu()" style="color: blue; cursor: pointer">【导出数据】</span>
                  <span>  <a style="text-decoration: none;" href="/record/insertemployee.html">【添加】</a></span>
                    <span onclick="todelete()" style="color: blue; cursor: pointer">【删除】</span>
            </span>
    </div>
    <br/>
    <form action="/record/deleteanddaochuemployee" method="post">
        <input type="hidden" id="method" name="method">
        <table cellpadding="4" cellspacing="0" border="1">
            <tr>
                <td width="30px;"><input type="checkbox" id="alleIds"/></td>
                <td>序号</td>
                <td>员工账号</td>
                <td>姓名</td>
                <td>手机号</td>
                <td>所属部门</td>
                <td>职位</td>
                <td>最后登录</td>
                <td>是否启动</td>
                <td>操作</td>
            </tr>
            <#list  emppage.list as empolyee>
                <tr>
                    <#if  empolyee.eId !=  currentUser.eId >
                        <td><input type="checkbox" name="eIds" value="${empolyee.eId!''}"/></td>
                    <#else >
                        <td></td>
                    </#if>
                    <td>${empolyee_index+1!''}</td>
                    <td>${empolyee.loginName!''}</td>
                    <td>${empolyee.eName!''}</td>
                    <td>${empolyee.eTel!''}</td>
                    <td>${empolyee.department.dName!''}</td>
                    <td>${empolyee.role.rName!''}</td>
                    <td>
                        <#if empolyee.eEndTime??>
                            ${empolyee.eEndTime?string("yyyy-MM-dd")}
                        </#if>
                    </td>
                    <#if  empolyee.eState == 1>
                        <td>启动</td>
                        <td>
                            <a href="/record/updateemployeepwd.html?eId=${empolyee.eId}">重置密码</a>
                            <a href="/record/updateemployee.html?eId=${empolyee.eId}">编辑</a>
                            <#if  empolyee.eId !=  currentUser.eId >
                                <a href="/record/deletemployee.html?eId=${empolyee.eId}">删除</a>
                            </#if>
                        </td>
                    <#else>
                        <td>禁用</td>
                        <td></td>
                    </#if>
                </tr>
            </#list>
            <tr>
                <td colspan="10">
                    <a href="/record/selectemployee?eName=${eName!''}&dId=${dId}">首页</a>
                    <a href="/record/selectemployee?index=${emppage.prePage}&eName=${eName!''}&dId=${dId}">上一页</a>
                    <a href="/record/selectemployee?index=${emppage.nextPage}&eName=${eName!''}&dId=${dId}">下一页</a>
                    <a href="/record/selectemployee?index=${emppage.pages}&eName=${eName!''}&dId=${dId}">尾页</a>
                    共${emppage.total}条 共${emppage.pageNum}/${emppage.pages}
                </td>
            </tr>
        </table>
    </form>
</#if>
</body>
</html>